package cn.village.service.impl;

import cn.village.dao.CompensationContractDao;
import cn.village.entity.CompensationContract;
import cn.village.service.CompensationContractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (CompensationContract)表服务实现类
 *
 * @author makejava
 * @since 2021-02-10 15:33:50
 */
@Service("compensationContractService")
public class CompensationContractServiceImpl implements CompensationContractService {
    @Resource
    private CompensationContractDao compensationContractDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public CompensationContract queryById(Integer id) {
        return this.compensationContractDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<CompensationContract> queryAllByLimit(int offset, int limit) {
        return this.compensationContractDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param compensationContract 实例对象
     * @return 实例对象
     */
    @Override
    public CompensationContract insert(CompensationContract compensationContract) {
        this.compensationContractDao.insert(compensationContract);
        return compensationContract;
    }

    /**
     * 修改数据
     *
     * @param compensationContract 实例对象
     * @return 实例对象
     */
    @Override
    public CompensationContract update(CompensationContract compensationContract) {
        this.compensationContractDao.update(compensationContract);
        return this.queryById(compensationContract.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.compensationContractDao.deleteById(id) > 0;
    }
}